"use strict";

/**
 * @desc   获取URL参数
 * @param  {String} key 
 * @param  {String} href default: window.location.href
 * @return {String}
 */
function getUrlKey(key, href) {
  return decodeURIComponent((new RegExp("[?|&]".concat(key, "=([^&;]+?)(&|#|;|$)")).exec(href ? href : location.href) || ["", ""])[1].replace(/\+/g, "%20")) || null;
}

module.exports = getUrlKey;